package com.ruoyi.project.pay.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.pay.domain.PayConfig;
import com.ruoyi.project.pay.service.IPayConfigService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 支付配置Controller
 * 
 * @author wyh
 * @date 2024-06-27
 */
@RestController
@RequestMapping("/payConfig/payConfig")
public class PayConfigController extends BaseController
{
    @Autowired
    private IPayConfigService payConfigService;

    /**
     * 查询支付配置列表
     */
    @PreAuthorize("@ss.hasPermi('payConfig:payConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(PayConfig payConfig)
    {
        startPage();
        List<PayConfig> list = payConfigService.selectPayConfigList(payConfig);
        return getDataTable(list);
    }

    /**
     * 导出支付配置列表
     */
    @PreAuthorize("@ss.hasPermi('payConfig:payConfig:export')")
    @Log(title = "支付配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PayConfig payConfig)
    {
        List<PayConfig> list = payConfigService.selectPayConfigList(payConfig);
        ExcelUtil<PayConfig> util = new ExcelUtil<PayConfig>(PayConfig.class);
        util.exportExcel(response, list, "支付配置数据");
    }

    /**
     * 获取支付配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('payConfig:payConfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(payConfigService.selectPayConfigById(id));
    }

    /**
     * 新增支付配置
     */
    @PreAuthorize("@ss.hasPermi('payConfig:payConfig:add')")
    @Log(title = "支付配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PayConfig payConfig)
    {
        return toAjax(payConfigService.insertPayConfig(payConfig));
    }

    /**
     * 修改支付配置
     */
    @PreAuthorize("@ss.hasPermi('payConfig:payConfig:edit')")
    @Log(title = "支付配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PayConfig payConfig)
    {
        return toAjax(payConfigService.updatePayConfig(payConfig));
    }

    /**
     * 删除支付配置
     */
    @PreAuthorize("@ss.hasPermi('payConfig:payConfig:remove')")
    @Log(title = "支付配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(payConfigService.deletePayConfigByIds(ids));
    }
}
